#pragma once

#include <iostream>

#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0);

#define CONV(v) (struct sockaddr *)(v)

enum
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR
};

bool SplitString(const std::string &line, std::string *key, std::string *val, const std::string &sep)
{
    auto pos = line.find(sep);
    if (pos == std::string::npos)
        return false;
    *key = line.substr(0, pos);
    *val = line.substr(pos + sep.size());
    if (key->empty() || val->empty())
        return false;
    return true;
}